diskinfo         Return


  ソース ファイル    diskinfo.zip



Pcのネットワ−クの状態を調べ、ListBoxに格納しC++BuilderのDrive コンポ-ネットのようなものを作成し利用しようと試みましたが 、ネットワ−クの状態を調べるの時間がかかり過ぎるようです。

Formに Button と TextBox を貼り付け、TextBox にDriveの名前、 DriveTyoe, VolumLabel名を表示しました。

RootDirectory、TotalFreeSpace、 TotalSize なども得られるので、それらも表示できます
using System.ComponentModel;
using System.Runtime.ExceptionServices;

namespace diskinfo
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
        private void Disp_hInfo(string s)
        {
            System.IO.DriveInfo drive = new System.IO.DriveInfo(s);

            if (drive.IsReady)
            {
                textBox1.AppendText(drive.Name + drive.DriveType+"  "+drive.VolumeLabel + "\r\n");
            }
            else
            {
                textBox1.AppendText(drive.Name + drive.DriveType + "\r\n");
            }
         }
        private void button1_Click(object sender, EventArgs e)
        {
            textBox1.Clear();
            string[] drives = Directory.GetLogicalDrives();

            foreach (string s in drives)
            {
                Disp_hInfo(s);
            }
        }
    }
}
System.IO.DriveInfo drive = new System.IO.DriveInfo(s); で

AvailableFreeSpace
DriveFormat
DriveType
IsReady
Name
RootDirectory
TotalFreeSpace
TotalSize
VolumeLabel

などの情報が得られる